
//
//  Costants.h
//  JiuLe
//
//  Created by xcq on 15/10/31.
//  Copyright © 2015年 Fine. All rights reserved.
//

#ifndef Costants_h
#define Costants_h
//网络环境测试

//测试环境
#ifdef DEBUG
//#define kURL @"http://203.88.170.163:8080"
#define kURL @"http://112.124.35.198:8089"
#else
////正式环境
#define kURL @"http://112.124.35.198:8089"
#endif

#define KBaseURL   [kURL stringByAppendingString:@"/api"]

// ================================== MD5 =======================
#define MD5Key              @"585bedd4e3d4a3cfa185f710914ad96c"
#define APP_URL             @"http://itunes.apple.com/lookup?id=你的应用程序的ID"
#define APP_DownLoad_URL    @"https://itunes.apple.com/us/app/qun-xiang-dao/id应用程序的ID?ls=1&mt=8"

// 自定义Log
#ifdef DEBUG
#define JLLog(...) NSLog(__VA_ARGS__)
#else
#define JLLog(...)
#endif


//导航栏返回按钮图片
#define KNavBarImage_highlighted @"navigationbar_back_highlighted"
#define KNavBarImage_normoal @"navigationbar_back"
#define kdeafaultImage          @"ic_image_default.jpg"
//#define kdefaultTouXiang          @"ic_wo_moren"
//180
#define kdefaultTouXiang          @"180"

// 获得RGB颜色
#define kClearColor [UIColor clearColor]
#define kAllBgColor MyColor(62, 188, 202)
#define kBlueColor  MyColor(37 , 122, 254)
#define kWhiteBgColor [UIColor whiteColor]
#define MyColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
#define separatorLineColor [UIColor colorWithRed:175/255.0 green:170/255.0 blue:154/255.0 alpha:1]
#define navigationBarBackgroundColor [UIColor colorWithRed:244/255.0 green:80/255.0 blue:80/255.0 alpha:1]
#define viewBgColor [UIColor colorWithRed:250/255.0 green:247/255.0 blue:240/255.0 alpha:1]
#define cellTitleColor [UIColor colorWithRed:118./255. green:116./255. blue:106./255. alpha:1]
#define menuTextColor [UIColor colorWithRed:132/255.0 green:125/255.0 blue:106/255.0 alpha:1]

//=======================适配(IOS6  &  IOS7)=================//
// 1.判断是否为iOS7
#define iOS7 ([[UIDevice currentDevice].systemVersion doubleValue] >= 7.0)

#pragma mark - For Compatibility (兼容)
// 对齐方式
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0
#define TextAlignmentLeft   NSTextAlignmentLeft
#define TextAlignmentCenter NSTextAlignmentCenter
#define TextAlignmentRight  NSTextAlignmentRight
#else
#define TextAlignmentLeft   UITextAlignmentLeft
#define TextAlignmentCenter UITextAlignmentCenter
#define TextAlignmentRight  UITextAlignmentRight
#endif
// 文本属性
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0
#define TextAttributeTextColor  NSForegroundColorAttributeName
#define TextAttributeFont       NSFontAttributeName
#else
#define TextAttributeTextColor  UITextAttributeTextColor
#define TextAttributeFont       UITextAttributeFont
#endif

// 多行文本获取高度
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0
#define multilineTextSize(text, font, maxSize) [text length] > 0 ? [text \
boundingRectWithSize:maxSize options:(NSStringDrawingUsesLineFragmentOrigin) \
attributes:@{NSFontAttributeName:font} context:nil].size : CGSizeZero;
#else
#define multilineTextSize(text, font, maxSize) [text length] > 0 ? [text \
sizeWithFont:font constrainedToSize:maxSize] : CGSizeZero;
#endif
// --------------------------判断屏幕尺寸 ----------------------//
/**
 *  1 判断是否为3.5inch      320*480
 */
#define ONESCREEN ([UIScreen mainScreen].bounds.size.height == 480)
/**
 *  2 判断是否为4inch        640*1136
 */
#define TWOSCREEN ([UIScreen mainScreen].bounds.size.height == 568)
/**
 *  3 判断是否为4.7inch   375*667   750*1334
 */
#define THREESCREEN ([UIScreen mainScreen].bounds.size.height == 667)
/**
 *  4 判断是否为5.5inch   414*1104   1242*2208
 */
#define FOURSCREEN ([UIScreen mainScreen].bounds.size.height == 736)


#define isDeviceIPad [[UIDevice currentDevice].model rangeOfString:@"iPad"]

// 当前IOS版本
#ifndef __CUR_IOS_VERSION
#define __CUR_IOS_VERSION ([[[UIDevice currentDevice] systemVersion] floatValue] * 10000)
#endif

//获取屏幕宽度
#define KScreenWidth  [UIScreen mainScreen].bounds.size.width
//获取屏幕高度
#define KScreenHeight [UIScreen mainScreen].bounds.size.height
#define kAppDelegate ((AppDelegate *)[UIApplication sharedApplication].delegate)
//====================== Notification ================//
#pragma mark - Notification
#define addObserver(_selector,_name)\
([[NSNotificationCenter defaultCenter] addObserver:self selector:_selector name:_name object:nil])

#define removeObserverWithName(_name)\
([[NSNotificationCenter defaultCenter] removeObserver:self name:_name object:nil])

#define removeObserver() ([[NSNotificationCenter defaultCenter] removeObserver:self])

#define postNotification(_name)\
([[NSNotificationCenter defaultCenter] postNotificationName:_name object:nil userInfo:nil])

#define postNotificationWithObject(_name, _obj)\
([[NSNotificationCenter defaultCenter] postNotificationName:_name object:_obj userInfo:nil])

#define postNotificationWithInfo(_name, _obj, _infos)\
([[NSNotificationCenter defaultCenter] postNotificationName:_name object:_obj userInfo:_infos])


// ---------------- 服务器返回数据为null的处理 ------------------
#define VerifyValue(value)\
({id tmp;\
if ([value isKindOfClass:[NSNull class]])\
tmp = nil;\
else\
tmp = value;\
tmp;\
})\

#endif /* Costants_h */
